﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'P_ListEnterprises')
	BEGIN
		DROP  Procedure  [esf_sso].P_ListEnterprises
	END

GO

CREATE Procedure [esf_sso].P_ListEnterprises
	@pPartName		VARCHAR (60) = NULL
	,@pListCount	INT = NULL
AS

	IF @pListCount IS NOT NULL
	BEGIN
		SET ROWCOUNT @pListCount
	END
	
	SELECT
		VE.Ent_ID
		,VE.Ent_Name
	FROM
		esf_sso.VEnterprise VE
	WHERE
		(@pPartName IS NULL OR VE.Ent_Name LIKE @pPartName)
	ORDER BY
		VE.Ent_Name

GO